// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'
import App from './App'
import router from './router'
// import '@/assets/styles/icon.css'
// eslint-disable-next-line
import 'jsencrypt'
import '@/assets/styles/global.scss'
import '@/assets/js/jquery-3.5.1.min.js'
import global from '@/assets/js/global.js'
import '@/assets/bootstrap/css/bootstrap.min.css'
import '@/assets/bootstrap/js/bootstrap.bundle.min'
// import '@/assets/js/index.js'
// import '@/assets/styles/index.css'
import '@/assets/mzui/js/mzui.min.js'
import '@/assets/mzui/fonts/zenicon.ttf'
import '@/assets/mzui/css/mzui.min.css'
import VuexPersistence from 'vuex-persist'

// import localforage from 'localforage'
Vue.config.productionTip = false

/* eslint-disable no-new */

Vue.use(global)
Vue.use(Vuex)
const vuexLocal = new VuexPersistence({
  // storage: localforage
  storage: sessionStorage
})
const store = new Vuex.Store({
  plugins: [vuexLocal.plugin],
  state () {
    return {
      avatarid: null,
      email: null,
      id: null,
      imgbase64: null,
      name: null,
      phone: null,
      token: null,
      discussion: null,
      loginflag: null,
      collection: []
    }
  },
  mutations: {
    setAvatarid (state, val) {
      state.avatarid = val
    },
    setId (state, val) {
      state.id = val
    },
    setEmail (state, val) {
      state.email = val
    },
    setImgbase64 (state, val) {
      state.imgbase64 = val
    },
    setName(state, val) {
      state.name = val
    },
    setPhone (state, val) {
      state.phone = val
    },
    setToken (state, val) {
      state.token = val
    },
    setDiscussion(state, val) {
      state.discussion = val
    },
    setLoginflag(state, val) {
      state.loginflag = val
    },
    setCollection(state, val) {
      state.collection = val
    },
    addCollection(state, val) {
      state.collection.push(val)
    },
    removeCollection(state, val) {
      let index = state.collection.indexOf(val)
      if (index > -1) {
        state.collection.splice(index, 1)
      }
    }
  }
})

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
